package com.miszczu.validators;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.miszczu.model.Classes;

@Component
public class ClassesValidator implements Validator {

	public boolean supports(Class<?> arg0) {
		
		return Classes.class.isAssignableFrom(arg0);
	}

	public void validate(Object object, Errors errors) {
		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "className", "errors.className", "Podaj nazwe klasy");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "classDescription", "errors.classDescription", "Podaj opis klasy");
		
	}


}
